//
// Created by moonlight on 25-7-23.
//
#include <iostream>
#include <list>
#include <string>
using namespace std;
class Person {
public:
    Person() {};
    Person(string name,int age,int height) {
        this->name = name;
        this->age = age;
        this->height = height;
    }
    string name;
    int age;
    int height;
};
//排序规则
bool compare(Person p1, Person p2) {
    if(p1.age == p2.age) {
        return p1.height > p2.height;
    }
    return p1.age < p2.age;
}
void test01() {
    list<Person> L;
    Person p1("lisi",35,166);
    Person p2("zhangsan",25,176);
    Person p3("wangwu",15,196);
    Person p4("guanyu",36,156);
    Person p5("wangerma",75,162);
    L.push_back(p1);
    L.push_back(p2);
    L.push_back(p3);
    L.push_back(p4);
    L.push_back(p5);
    cout << L.size() << endl;

    for (list<Person>::iterator it = L.begin(); it != L.end(); it++) {
        cout << (*it).name << " " << (*it).age << " " << (*it).height <<"\t ";
    }
    //sort
    cout << endl;
    L.sort(compare);

    for (list<Person>::iterator it = L.begin(); it != L.end(); it++) {
        cout << (*it).name << " " << (*it).age << " " << (*it).height <<"\t ";
    }
}
int main() {
    test01();
    return 0;
}